<template>
  <div class="commonTitle">
    <div class="label">
      <span class="text">{{ displayText }}</span>
    </div>
    <div class="center">
      <slot name="center"></slot>
    </div>
    <div class="expand">
      <slot name="expand"></slot>
    </div>
  </div>
</template>

<script setup>
import { useRoute } from 'vue-router'
import { computed } from 'vue'


const props = defineProps({
  text: {
    type: String,
    required: false,
    default: undefined
  },
});
const route = useRoute()

const displayText = computed(() =>
  props.text ?? route.meta.title ?? ''
)
</script>

<style scoped lang="scss">
.commonTitle {
  position: relative;
  height: 50px;
  line-height: 50px;
  background: #fff;

  .label {
    position: absolute;
    left: 20px;
    display: flex;
    line-height: 50px;
    align-items: center;
    font-size: 16px;
    font-weight: bold;


    &:before {
      content: "";
      width: 5px;
      height: 24px;
      background: #409eff;
      margin-right: 10px;
    }
  }

  .expand {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
  }
}
</style>
